/*
countingIterator:  Fancy iterator, this iterator brings a sequence
                   of increasing values.
    Copyright (C) 2012  Jorge E. A. Atala
                        FuDePAN
    This file is part of the Fui Proyect.

    Fui is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Fui is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Fui.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef COUNTING_ITERATOR_IMP
#   error This is an internal file, do not include. Include countingIterator.h instead.
#else
namespace fui
{
template<class T>
CountingIterator<T>::CountingIterator(T x)
    :   x(x)
{}

template<class T>
T CountingIterator<T>::operator*() const
{
    T output = x;
    return output;
}
template<class T>
T CountingIterator<T>::operator[](const size_t index) const
{
    T output = x + index;
    return output;
}

template<class T>
CountingIterator<T> CountingIterator<T>::operator+(const size_t index) const
{
    return CountingIterator<T>(x + index);
}

template<class T>
CountingIterator<T> CountingIterator<T>::operator-(const size_t index) const
{
    return CountingIterator<T>(x - index);
}

template<class T>
CountingIterator<T> CountingIterator<T>::operator-(const CountingIterator<T> other) const
{
    return CountingIterator<T>(x - other.x);
}

template<class T>
CountingIterator<T>& CountingIterator<T>::operator++()
{
    ++x;
    return *this;
}

template<class T>
CountingIterator<T>& CountingIterator<T>::operator--()
{
    --x;
    return *this;
}

template<class T>
CountingIterator<T> CountingIterator<T>::operator++(const int)
{
    CountingIterator<T> output(x++);
    return output;
}

template<class T>
CountingIterator<T> CountingIterator<T>::operator--(const int)
{
    CountingIterator<T> output(x--);
    return output;
}
template<class T>
bool CountingIterator<T>::operator==(const CountingIterator<T>& other)const
{
    return x == other.x;
}

template<class T>
bool CountingIterator<T>::operator!=(const CountingIterator<T>& other)const
{
    return x != other.x;
}

template<class T>
bool CountingIterator<T>::operator<(const CountingIterator<T>& other)const
{
    return x < other.x;
}
}

#endif
